package com.jacky.launcher.video;

import android.app.Activity;
import android.os.Bundle;

import com.jacky.launcher.R;
import com.jacky.launcher.detail.MediaModel;
import com.shuyu.gsyvideoplayer.GSYVideoManager;
import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer;


public class VideoViewActivity extends Activity {

    public static final String VIDEO = "Video";
    private StandardGSYVideoPlayer videoPlayer;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_video_view);
        MediaModel mMediaModel = getIntent().getParcelableExtra(VideoViewActivity.VIDEO);
        videoPlayer =  findViewById(R.id.video_player);
        //添加播放控制条,还是自定义好点
        videoPlayer.setUp(mMediaModel.getVideoUrl(), false, mMediaModel.getTitle());
//        mVideoView.setVideoURI(Uri.parse(mMediaModel.getVideoUrl()));
        videoPlayer.startPlayLogic();
    }

    @Override
    public void onBackPressed() {
        super.onBackPressed();
    }

    @Override
    protected void onResume() {
        super.onResume();
        videoPlayer.onVideoResume();
    }

    @Override
    protected void onPause() {
        super.onPause();
        videoPlayer.onVideoPause();
    }

    @Override
    protected void onStop() {
        super.onStop();
        //释放所有
        videoPlayer.setVideoAllCallBack(null);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        GSYVideoManager.releaseAllVideos();
    }
}
